Exercise: Predicting Election Results
In this exercise, you will predict election results from a sample of randomly chosen people.
We'll cover the following
Task#
Consider an election where one million (1,000,000) people will vote.
-
490,000 people will vote for Mr. Arthur
-
510,000 people will vote for Mr. Ben.
One day before the election, a private company, Octavius, conducts a poll among 1000 randomly chosen voters.
Problem statement 1#
Compute whether Octavius will predict the winner correctly using the approach explained above and print the answer. Voters of Arthur are identified by and those of Ben are identified by .
Use the choice function to extract random values from the voter sample.
Set the value of
seedto 2.
Problem statement 2#
Perform the poll 1000 times. Count how many times Arthur wins and how many times Ben wins.
Also, find the probability that Octavius will predict the correct winner based on these 1000 polls of 1000 people.
Set the value of
seedto 2.
The solution to this exercise will be discussed in the next lesson.
Quiz 11!
Solution Review: Predicting Election Results